package com.huluobo.roomdemo;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * Created by LC on 2024/9/20.
 * Dao Database 转化为 Object
 * 在Room中,这里标记的是增删改查的方法
 * onConflict = OnConflictStrategy.REPLACE 替换规则,当重复插入数据的时候,会替换原有的数据
 */
@Dao
public interface UserDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertUserInfo(UserBean userBean);

    @Delete
    void deleteUserInfo(UserBean userBean);

    @Update
    void updateUserInfo(UserBean userBean);

    @Query("select * from user_info")
    List<UserBean> queryUserInfo();

    @Query("select * from user_info where username=:name")
    UserBean queryUserInfoByName(String name);
}
